{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">收益管理</div>
    <div class="layui-card-body">


        <button type="button" name="myfile"  class="btn layui-btn faupload" style="margin-bottom: 10px;">导入数据</button>

        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('notice/add')}"
                   data-auth-edit="{:$auth->check('notice/edit')}"
                   data-auth-delete="{:$auth->check('notice/del')}"></table>
        </div>
    </div>

</div>

<script type="text/html" id="barTool">
    <a data-open='{:url("edit")}?id={{ d.id }}' class="layui-btn layui-btn-xs {:$auth->check('notice/edit')?'':'layui-hide'}" title="编辑"><i class='iconfont icon-brush_fill'></i></a>
    <a href='{:url("del")}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('notice/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a></script>

{/block}
{block name="script"}
<script type="text/javascript">
layui.use(['yznTable', 'yznUpload'], function() {
    var table = layui.yznTable;
    var yznUpload = layui.yznUpload;

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTable',
        modify_url:'{:url("multi")}',
        add_url: '{:url("add")}',
        edit_url: '{:url("edit")}',
        delete_url: '{:url("del")}',

    };






    table.render({
        init: init,
        toolbar: ['refresh','delete'],
        url: '{:url("index")}',
        cols: yznTable.formatCols([
            [
                { type: 'checkbox', fixed: 'left' },
                { field: 'uid', width: 140, align: 'center', title: 'UID'},
                { field: 'day', width: 140, align: 'center', title: '日期'},
                { field: 'username',width: 120,align: 'center',  title: '主播昵称', searchOp: 'like' },
                { field: 'zid',width: 120,align: 'center',  title: '主播ID', searchOp: 'like' },
                { field: 'cid',width: 120,align: 'center',  title: '场次ID',  },
                { field: 'cate',width: 120,align: 'center',  title: '内容赛道', searchOp: 'like' },
                { field: 'status',width: 120,align: 'center',  title: '申诉状态',  },
                { field: 'scarcity',width: 120,align: 'center',  title: '内容稀缺度', },
                { field: 'stop_time',width: 120,align: 'center',  title: '推荐有效用户停留时长（分钟）', search: false},
                { field: 'valid_time',width: 120,align: 'center',  title: '预估平均有效内容指数', search: false},
                { field: 'level',width: 120,align: 'center',  title: '内容质量等级'},
                { field: 'price',width: 120,align: 'center',  title: '内容质量等级对应单价',search: false},
                { field: 'is_ctb',width: 120,align: 'center',  title: '是否结算'},
                { field: 'reason',width: 120,align: 'center',  title: '不结算原因',search: false},
                { field: 'money',width: 120,align: 'center',  title: '预估奖励金额（元）',search: false},
                { field: 'create_time',width: 120,  align: 'center', title: '创建时间',search: 'range'},
                { fixed: 'right', align: 'center', width: 140, title: '操作', toolbar: '#barTool' }
            ]
        ],init),
        page: {},
        done: function (res, curr, count) {
            yznUpload.api.upload('.faupload', function (data, ret) {
                var path = data.path;
                if (path) {
                    yzn.request.post({
                        url: '{:url("income/import")}',
                        data: {
                            path: path
                        }
                    }, function (data, res) {
                        yzn.msg.alert(res.msg,function (msg) {
                            window.location.reload();
                        });
                    });
                } else {
                    yzn.msg.success('上传失败');
                }

            });
        }
    });
    yznTable.listenSwitch({filter: 'status', url: init.modify_url});
    yznTable.listenSwitch({filter: 'type', url: init.modify_url});

    yznTable.bindevent();
});
</script>
{/block}